package firstping.controller;

import java.io.IOException;
import java.util.List;
import java.util.regex.Pattern;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import firstping.data.QnAPersistenceManager;
import firstping.model.Domain;
import firstping.model.SaveDomain;


@SuppressWarnings("serial")
public class RssServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		PersistenceManager psm = QnAPersistenceManager.get().getPersistenceManager();

		Query query_article = psm.newQuery(Domain.class);
		query_article.setOrdering("lastUpdateDate desc");
		query_article.setRange(0, 30);
		@SuppressWarnings({ "unchecked" })
		List<Domain> listDomains = (List<Domain>) query_article.execute();
		
		req.setAttribute("listDomains", listDomains);
		
		req.setAttribute("title", "We provide web site monitoring to webmasters");
		req.setAttribute("description", "We provide web site monitoring to webmasters. Monitor your web site is availability 24 hours a day, 7 days a week with instant email alerts and weekly web site performance statistics.");
		
		try {
			req.getRequestDispatcher("/rss.jsp").forward(req, resp);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
